#
# A simple list scene graph.
#
# Auther: Wesley Liu
# Email: jinvy.liu@gmail.com
# Date: 12/19/2007
#

require File.dirname(__FILE__) + '/IScene'
require File.dirname(__FILE__) + '/AABB'

class ListScene < IScene

    def initialize
        super
        @meshes = Array.new
    end
    
    def each
        @meshes.each { |mesh| yield mesh}
    end
    
    def addmesh m
        @meshes[@meshes.length] = m
    end
    
    def rootbb
        if @rootbb == nil
            @rootbb = AABB.new
            @meshes.each do |mesh|
                @rootbb += mesh.getAABB
            end        
        end
        @rootbb
    end
end